<?php
if (!isset($_SESSION['logged']))
    print "<script language='javascript'>
        window.location.href='./?url=404';
        </script>";
else {
    $idfile = $_GET['file'];
    $sql = "SELECT * FROM `file` WHERE `id` = '$idfile';";
    $result = mysql_query($sql, $link);
    $rowFile = mysql_fetch_assoc($result);
?>
<div id="mainCol" class="clearfix">
    <h3 id="why">Edit file</h3>
    <ul id="maincon">
        <li class="clearfix last">
            <fieldset id="forms">
            <table width="100%">
                <form method="post" id="postform" action="?url=fileediting">
                    <input type="hidden" name="idfile" value="<?= $idfile; ?>">
                    <tr>
                        <td valign="top" width="25%"><b>Title:</b></td>
                        <td><input type="text" maxlength="200" name="title" id="f_input" size="55" value="<?= $rowFile['title']; ?>" /></td>
                    </tr>
                    <tr>
                        <td valign="top" width="25%"><b>Type:</b></td>
                        <td>
<?
    $sql = "SELECT * FROM `type`;";
    $result = mysql_query($sql, $link);
    $array_types = array();
    while ($row = mysql_fetch_assoc($result)) {
        if($row['id']==$rowFile['type_id']){
?>
                            <input type="radio" name="type" checked value="<?= $row['id']; ?>"/> <?= $row['title']; ?><br />
<?
        }else{
?>
                            <input type="radio" name="type" value="<?= $row['id']; ?>"/> <?= $row['title']; ?><br />
<?
        }
        $array_types[$row['id']] = $row['title'];
    }
?>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" width="25%"><b>Description:</b></td>
                        <td><textarea name="description" style="width: 99%" rows="7"><?= $rowFile['description']; ?></textarea></td>
                    </tr>
                    <tr>
                        <td valign="top" width="25%"><b>Link:</b></td>
                        <td><input type="text" name="link" id="f_input" size="55" value="<?= $rowFile['link']; ?>" /></td>
                    </tr>
                    <tr>
                        <td colspan="2"><input id="f_submit" type="submit" value="Save" /></td>
                    </tr>
                </form>
            </table>
            </fieldset>
        </li>
    </ul>
</div>
<?
                       }
?>
